#@layout()
#define main()
	<div>
		<div style="margin:5px 0;border-bottom:1px solid #aaa;">
			<span class="layui-breadcrumb">
				<a href="xpApi">服务接口说明</a>
				<a><cite>测试</cite></a>
			</span>
        </div>
		<form id="form1" class="layui-form" action="xpApi/call" method="post" style="padding:0px 0 0 20px;">
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label" style="width:90px;">接口名称</label>
					<div class="layui-input-inline">
						<input class="layui-input" type="text" name="method"  value="#(name)" readonly>						
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label" style="width:90px;">密码</label>
					<div class="layui-input-inline">
						<input class="layui-input" type="text" name="password"  value="#(password)">						
					</div>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label" style="width:90px;">参数1名</label>
					<div class="layui-input-inline">
						<input class="layui-input" type="text" name="paramName1"  value="#(paramName1)">						
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label" style="width:90px;">参数1值</label>
					<div class="layui-input-inline">
						<input class="layui-input" type="text" name="paramValue1"  value="#(paramValue1)">						
					</div>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label" style="width:90px;">参数2名</label>
					<div class="layui-input-inline">
						<input class="layui-input" type="text" name="paramName2"  value="#(paramName2)">						
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label" style="width:90px;">参数2值</label>
					<div class="layui-input-inline">
						<input class="layui-input" type="text" name="paramValue2"  value="#(paramValue2)">						
					</div>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label" style="width:90px;">参数3名</label>
					<div class="layui-input-inline">
						<input class="layui-input" type="text" name="paramName3"  value="#(paramName3)">						
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label" style="width:90px;">参数3值</label>
					<div class="layui-input-inline">
						<input class="layui-input" type="text" name="paramValue3"  value="#(paramValue3)">						
					</div>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label" style="width:90px;">参数4名</label>
					<div class="layui-input-inline">
						<input class="layui-input" type="text" name="paramName4"  value="#(paramName4)">						
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label" style="width:90px;">参数4值</label>
					<div class="layui-input-inline">
						<input class="layui-input" type="text" name="paramValue4"  value="#(paramValue4)">						
					</div>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label" style="width:90px;">参数5名</label>
					<div class="layui-input-inline">
						<input class="layui-input" type="text" name="paramName5"  value="#(paramName5)">						
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label" style="width:90px;">参数5值</label>
					<div class="layui-input-inline">
						<input class="layui-input" type="text" name="paramValue5"  value="#(paramValue5)">						
					</div>
				</div>
			</div>
			<div class="layui-form-item">
				<div style="text-align: center;">
					<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
					<a href="xpApi" class="layui-btn layui-btn-primary">返回</a>
				</div>
			</div>
		</form>
		<div style="padding:0px 0 0 20px;">
			<div class="layui-inline">
				<label class="layui-form-label" style="width:90px;">测试结果</label>
				<div class="layui-input-inline" style="width: 465px;">
			      <textarea placeholder="请输入内容" class="layui-textarea" id="result"></textarea>
			    </div>
			</div>
		</div>
	</div>
	<script src="xpsoft/common/js/md5.js"></script>
	<script>
	layui.use(['form', 'laydate'], function(){
		var form = layui.form
		,layer = layui.layer
		,laydate = layui.laydate;


		//自定义验证规则
//			form.verify({
//				userName: function(value){
//					if(value.length < 5){
//						return '用户名至少得5个字符啊';
//					}
//				},
//			});

		//监听指定开关
//			form.on('select(changeID)', function(data){
//				if(data.value!="#(departmentID)")
//				{
//					$("#role").css("display","none");
//					$("input[name='role']").removeAttr("checked");
//					form.render('checkbox');
//				}
//				else
//				{
//					if($("#type").val()=="2")
//						$("#role").css("display","block");
//					else
//					{
//						$("#role").css("display","none");
//						$("input[name='role']").removeAttr("checked");
//					}
//					form.render('checkbox');
//				}
//			});
		
		//监听指定开关
//			form.on('select(changetype)', function(data){
//				if(data.value=="1")
//				{
//					$("#role").css("display","none");
//					$("input[name='role']").removeAttr("checked");
//					form.render('checkbox');
//				}
//				else
//				{
//					if($("#departmentID").val()=="#(departmentID)")
//						$("#role").css("display","block");
//					else
//					{
//						$("#role").css("display","none");
//						$("input[name='role']").removeAttr("checked");
//					}
//					form.render('checkbox');
//				}
//			});
		
		//监听指定开关
		form.on('switch(switchState)', function(data){
//				$("#userstate").val(this.checked ? '1' : '0');
		});

		//监听提交
		form.on('submit(demo1)', function(data){
			var $form=$("#form1");
			var data={"userName":"#(userName)","curTime":new Date().getTime(),"method":$("input[name='method']").val()};
			for(var i=1;i<=5;i++)
			{
				if($("input[name='paramName"+i+"']").val().length!=0)	
					data['"'+$("input[name='paramName"+i+"']").val()+'"']=$("input[name='paramValue"+i+"']").val();
			}
			var myArray=new Array();
			i=0;
			for(k in data)
			{
				myArray[i]=k;
				i++;
			}
			myArray.sort();
			var sn="";
			for(i=0;i<myArray.length;i++)
				sn+=data[myArray[i]];
			data.sn=MD5(sn+$("input[name='password']").val());
			//var data=JSON.parse(txt);
			$.getJSON("xpApi/call",data,function(json){
				$("#result").val(JSON.stringify(json));
				})
			return false;
				//layer.alert(JSON.stringify(data.field), { title: '最终的提交信息' });
				//return false;
//				$("#userID").removeAttr("disabled");
		});
	});
	
$(function(){		
	#if(msg)
		xpsoft.msg('#(msg)');
	#end
});	
	</script>
#end